package org.gdstash.item;

import org.gdstash.db.*;

import java.util.LinkedList;
import java.util.List;

public class ItemInfo {
    public List<DBStat> itemStats;
    public List<DBStat> petStats;
    public List<DBStat> componentStats;
    public List<DBStat> completionStats;
    public List<DBStat> enchantmentStats;
    public List<DBSkillBonus> itemSkillBonuses;
    public List<DBSkillBonus> componentSkillBonuses;
    public List<DBSkillBonus> completionSkillBonuses;
    public List<DBSkillModifier> skillModifiers;
    public List<Skill> itemSkills;
    public List<Skill> petSkills;
    public List<Skill> componentSkills;
    public List<Skill> completionSkills;

    public ItemInfo() {
        this.itemStats = new LinkedList<DBStat>();
        this.petStats = new LinkedList<DBStat>();
        this.componentStats = new LinkedList<DBStat>();
        this.completionStats = new LinkedList<DBStat>();
        this.enchantmentStats = new LinkedList<DBStat>();
        this.itemSkillBonuses = new LinkedList<DBSkillBonus>();
        this.itemSkillBonuses = new LinkedList<DBSkillBonus>();
        this.componentSkillBonuses = new LinkedList<DBSkillBonus>();
        this.completionSkillBonuses = new LinkedList<DBSkillBonus>();
        this.skillModifiers = new LinkedList<DBSkillModifier>();
        this.itemSkills = new LinkedList<Skill>();
        this.petSkills = new LinkedList<Skill>();
        this.componentSkills = new LinkedList<Skill>();
        this.completionSkills = new LinkedList<Skill>();
    }

    public static class Skill {
        private DBSkill dbSkill;
        private int level;
        private DBController dbController;

        Skill(final DBSkill skill, final int level, final DBController controller) {
            this.dbSkill = skill;
            this.dbController = controller;
            if (level > 0) {
                this.level = level;
            } else {
                this.level = 1;
            }
        }

        Skill(final DBSkill skill, final int level) {
            this.dbSkill = skill;
            this.dbController = null;
            if (level > 0) {
                this.level = level;
            } else {
                this.level = 1;
            }
        }

        public DBSkill getSkill() {
            return this.dbSkill;
        }

        public DBController getController() {
            return this.dbController;
        }

        public String getControllerTriggerType() {
            if (this.dbController == null) {
                return null;
            }
            return this.dbController.getTriggerType();
        }

        public int getControllerTriggerChance() {
            if (this.dbController == null) {
                return 0;
            }
            return this.dbController.getTriggerChance();
        }

        public int getLevel() {
            return this.level;
        }
    }
}
